<?php

namespace app\common\model;

use think\Model;

/**
 * 短信验证码
 */
class WithdrawRequest extends Model
{

    // 开启自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    // 追加属性
    protected $append = [
        'create_time_text',
        'status_text',
    ];

    public function getCreateTimeTextAttr($value, $data)
    {
        $value = $data['createtime'] ?? 0;

        return $value ? date('Y/m/d H:i', $value) : '';
    }

    public function getStatusTextAttr($value, $data)
    {
        $value = $data['status'] ?? 0;

        $status = [
            1 => '申请中',
            2 => '已拒绝',
            3 => '已发放',
        ];

        return $status[$value] ?? '';
    }
}
